﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace lcs.Web.Admin.TimeLine
{
    public partial class indexnum : System.Web.UI.Page
    {
        Maticsoft.BLL.project bll = new Maticsoft.BLL.project();
        Maticsoft.BLL.supplyPlan bs = new Maticsoft.BLL.supplyPlan();
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!Page.IsPostBack)
            //{
            //    DataSet ds = bll.GetAllList();
            //    ddlproject.DataSource = ds.Tables[0];
            //    ddlproject.DataTextField = "projectName";
            //    ddlproject.DataValueField = "projectId";
            //    ddlproject.DataBind();
            //}

        }
        public void BindData()
        {
            DataSet ds = new DataSet();

            //int projectId = int.Parse(ddlproject.SelectedValue);

            string where = "";
            if (txtSearch.Text.Trim() != "")
                where += " and projectname='" + txtSearch.Text.Trim() + "'";

            if (!string.IsNullOrEmpty(this.txt_material.Text))
            {
                where += " and material like '%" + txt_material.Text + "%' ";
            }

            ds = bs.GetListnumsbyid(where);
            if (ds.Tables[0].Rows.Count > 0)
            {
                //lh1.Text = "共有" + ds.Tables[0].Rows.Count.ToString() + "条";
                lt0.Text = "";
                lt1.Text = "";
                lt2.Text = "";
                lt3.Text = "";
                lt4.Text = "";
                lt5.Text = "";
                lt6.Text = "";
                if (!string.IsNullOrEmpty(this.txt_material.Text))
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (i != ds.Tables[0].Rows.Count - 1)
                        {
                            lt0.Text +="物料："+ ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["num"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["supplyPDate"].ToString() + "<br />";
                            lt1.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["thisMonthCount"].ToString() + "时间：" + ds.Tables[0].Rows[i]["supplyDate"].ToString() + "<br />";
                            lt2.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["nums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["ddate"].ToString() + "<br />";
                            lt3.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["aognums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastArrivalDate"].ToString() + "<br />";
                            lt4.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["pinums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastCheckedDate"].ToString() + "<br />";
                            lt5.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["innums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastInstoreDate"].ToString() + "<br />";
                            lt6.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["outnums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastouttime"].ToString() + "<br />";
                        }
                        else
                        {
                            lt0.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["num"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["supplyPDate"].ToString() ;
                            lt1.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["thisMonthCount"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["supplyDate"].ToString() ;
                            lt2.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["nums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["ddate"].ToString() ;
                            lt3.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["aognums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastArrivalDate"].ToString() ;
                            lt4.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["pinums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastCheckedDate"].ToString() ;
                            lt5.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["innums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastInstoreDate"].ToString() ;
                            lt6.Text += "物料：" + ds.Tables[0].Rows[i]["material"].ToString() + " 数量：" + ds.Tables[0].Rows[i]["outnums"].ToString() + " 时间：" + ds.Tables[0].Rows[i]["lastouttime"].ToString() ;
                        }
                    }
                }
                else
                {
                    int num0=0,num1 = 0, num2 = 0, num3 = 0, num4 = 0, num5 = 0, num6 = 0;
                    num0 = ds.Tables[0].Rows.Count;
                    for (int i = 0; i < num0; i++)
                    {
                        if (ds.Tables[0].Rows[i]["supplyDate"].ToString().Trim() != "")
                            num1++;
                        if (ds.Tables[0].Rows[i]["ddate"].ToString().Trim() != "")
                            num2++;
                        if (ds.Tables[0].Rows[i]["lastArrivalDate"].ToString().Trim() != "")
                            num3++;
                        if (ds.Tables[0].Rows[i]["lastCheckedDate"].ToString().Trim() != "")
                            num4++;
                        if (ds.Tables[0].Rows[i]["lastInstoreDate"].ToString().Trim() != "")
                            num5++;
                        if (ds.Tables[0].Rows[i]["lastouttime"].ToString().Trim() != "")
                            num6++;
                    }
                    lt0.Text = num0 + ":" + num0 + " 完成比例为" + (((float)num0 / num0) * 100).ToString("F2") + "%";
                    lt1.Text = num1 + ":" + num0 + " 完成比例为" + (((float)num1 / num0) * 100).ToString("F2") + "%";
                    lt2.Text = num2 + ":" + num0 + " 完成比例为" + (((float)num2 / num0) * 100).ToString("F2") + "%";
                    lt3.Text = num3 + ":" + num0 + " 完成比例为" + (((float)num3 / num0) * 100).ToString("F2") + "%";
                    lt4.Text = num4 + ":" + num0 + " 完成比例为" + (((float)num4 / num0) * 100).ToString("F2") + "%";
                    lt5.Text = num5 + ":" + num0 + " 完成比例为" + (((float)num5 / num0) * 100).ToString("F2") + "%";
                    lt6.Text = num6 + ":" + num0 + " 完成比例为" + (((float)num6 / num0) * 100).ToString("F2") + "%";

                }
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            BindData();
        }

    }
}